#include "companySelector.h"
#include <stdio.h>
#include "game.h"

void CompanySelector::draw(Graphics * g){
	sprintf_s(g->TEXT, g->TEXT_SIZE, "     Company siz stock cost($) market cap");
	g->drawText(g->TEXT, loc.x, loc.y);
	TileGroup * c;
	int color, marketcap;
	for(int i = 1; i < m_companies->size; ++i)
	{
		c = &m_companies->list[i];
		color = selectability.list[i].visible
			?(selectability.list[i].selectable
				?c->getColor()
				:Graphics::DARK_GRAY)
			:Graphics::BLACK;
		if(index == i){
			color = m_game->flashColor(1);
		}
		marketcap = (TileGroup::MAX_SHARES - c->getFreeShares()) * c->getShareCost();
		sprintf_s(g->TEXT, g->TEXT_SIZE, "%c%11s %2d  %3d  %5d   %10d", 
			c->getSize()?' ':'?', c->getName(), c->getSize(), c->getFreeShares(), c->getShareCost(), marketcap);
		g->drawText(g->TEXT, loc.x, loc.y+i, color);
	}
}
